package com.yuanfeng.base.controller;

import com.yuanfeng.base.dto.NavSortLogoVO;
import com.yuanfeng.base.dto.SystemConfigHallDTO;
import com.yuanfeng.base.dto.WebConfigDTO;
import com.yuanfeng.commoms.constant.CommonStatusEnum;
import com.yuanfeng.commoms.dto.goods.NavSortLogoDTO;
import com.yuanfeng.commoms.dto.userms.UserTokenBeanDTO;
import com.yuanfeng.commoms.util.ResponseResult;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ClassName BaseSysConfigsController
 * @Description 基础配置
 * @Author hyq
 * @Date 2023/5/19 17:24
 * @Version 1.0
 **/
@RestController
@RequestMapping("base/sysConfig")
public class BaseSysConfigsController extends BaseController {

    /**
     * 根据configKey 查询根据configValue
     */
    @PostMapping("queryConfigKeyFeign")
    public String selectConfigValueFeign(@RequestParam("configKey") String configKey) {

        return baseSysConfigsService.selectConfigValueFeign(configKey);
    }

    /**
     * 查询首页logo
     */
    @PostMapping("/quertNavLogo")
    public ResponseResult quertNavLogo(@RequestBody NavSortLogoDTO gdbNavSortLogoDTO) {

        return baseSysConfigsService.quertNavLogo(gdbNavSortLogoDTO);
    }

    /**
     * 根据configKey 查询配置
     *
     * @param configKey
     * @return
     */
    @GetMapping("/selectByConfigKey")
    public ResponseResult selectByConfigKey(@RequestParam("configKey") String configKey) {
        return baseSysConfigsService.selectByConfigKey(configKey);
    }
    /**
     * 查询 pc h5 积分商城首页
     */
    @PostMapping("/integral/queryIndex")
    public ResponseResult queryIntegralIndex(@RequestBody Map<String,String> param){
        return baseSysConfigsService.queryIntegralIndex(param);
    }

    /**
     * 查询商城客服及邮箱
     *
     * @param param
     * @return
     */
    @PostMapping("/queryPhoneAndMail")
    public ResponseResult queryPhoneAndMail(@RequestBody UserTokenBeanDTO param) {
        ResponseResult result = null;
        try {
            result = baseSysConfigsService.queryPhoneAndMail(param);
        } catch (Exception e) {
            return ResponseResult.fail(CommonStatusEnum.FAIL.getCode(),e.getMessage());
        }
        return result;
    }

    /**
     * 开启配置
     *
     * @param configKey
     * @return
     */
    @GetMapping("/updateConfig")
    public ResponseResult updateConfigEnableByConfigKey(@RequestParam("configKey") String configKey,@RequestParam("configEnable") String configEnable) {
        return baseSysConfigsService.updateConfigEnableByConfigKey(configKey,configEnable);
    }

    /**
     * 查询app首页轮播
     *
     * @param param
     * @return
     */
    @PostMapping( "/supply/slide/query")
    public ResponseResult querySupplyIndexSlide(@RequestBody Map<String,Object> param) {
        return baseSysConfigsService.querySupplyIndexSlide(param);
    }

    /**
     * 更新轮播下广告
     *
     * @param param
     * @return
     */
    @PostMapping("/adPage/update")
    public ResponseResult updateAdPage(@RequestBody SystemConfigHallDTO param) {
        try {
            ResponseResult result = baseSysConfigsService.updateAdPage(param);
            return result;
        } catch (Exception e) {
            return ResponseResult.fail(e.getMessage());
        }
    }

    /**
     * 品牌店铺热搜词
     */
    @PostMapping("/selectHotWord")
    public ResponseResult selecthotword(@RequestBody Map<String,Object> param) {
        return baseSysConfigsService.selecthotword(param);
    }

    /**
     * 平台修改入驻设置
     *
     * @param dto
     * @return
     */
    @PostMapping("/joinSetting/update")
    public ResponseResult updateJoinSetting(@RequestBody SystemConfigHallDTO dto) {
        return baseSysConfigsService.updateSysConfigByKey(dto);
    }

    /**
     * 平台查询入驻设置
     *
     * @param param
     * @return
     */
    @PostMapping("/joinSetting/query")
    public ResponseResult queryjoinSetting(@RequestBody Map<String,Object> param) {
        return baseSysConfigsService.querySysConfigByKey(param);

    }

    /**
     * 获取企业注册密码规则
     *
     * @return
     */
    @PostMapping("/business/passwordConfig")
    public ResponseResult businessPasswordConfig() {
        return baseSysConfigsService.businessPasswordConfig();
    }

    /**
     * 获取企业注册密码规则
     *
     * @return
     */
    @PostMapping("/queryBusinessConfig")
    public ResponseResult queryBusinessConfig() {
        return baseSysConfigsService.queryBusinessConfig();
    }

    /**
     * 获取configValue
     *
     * @param configKey
     * @param configType
     * @return
     */
    @GetMapping("/selectByKeyAndType")
    public ResponseResult getConfigValue(@RequestParam("configKey") String configKey,
                                         @RequestParam("configType") String configType) {
        return baseSysConfigsService.getConfigValue(configKey,configType);
    }

    /**
     * 平台 主题设置  移动端 查询
     *
     * @param param
     * @return
     */
    @PostMapping("/themeH5Color/query")
    public ResponseResult queryThemeH5ColorSetting(@RequestBody Map<String,Object> param) {
        return baseSysConfigsService.queryThemeH5ColorSetting(param);
    }

    /**
     * 平台 主题设置  pc商城主题  修改
     *
     * @param webConfig
     * @return
     */
    @PostMapping("/themeColor/update")
    public ResponseResult updateThemeColorPageSetting(@RequestBody WebConfigDTO webConfig) {
        return baseSysConfigsService.updateThemeColorPageSetting(webConfig);
    }

    /**
     * 平台 商城配置  文案设置修改
     *
     * @param gdbNavSortLogoDTOs
     * @return
     */
    @PostMapping("/commonSort/logo")
    public ResponseResult updateNavCommonSortLogo(@RequestBody NavSortLogoVO gdbNavSortLogoDTOs) {
        return baseSysConfigsService.updateNavCommonSortLogo(gdbNavSortLogoDTOs);
    }

    /**
     * 平台 商城配置  文案设置修改
     *
     * @param map
     * @return
     */
    @PostMapping(value="/commonSort/logoString")
    public ResponseResult updateNavCommonSortLogo2(@RequestBody Map<String, String> map){
        return baseSysConfigsService.updateNavCommonSortLogo2(map);
    }

    /**
     * 广告图查询
     * @param param
     * @return
     */
    @PostMapping("/queryAdvertising")
    public ResponseResult queryadvertising(@RequestBody Map<String,Object> param) {
        return baseSysConfigsService.queryadvertising(param);
    }

    /**
     * 广告图修改
     * @param param
     * @return
     */
    @PostMapping("/updateAdvertising")
    public ResponseResult updateAdvertising(@RequestBody Map<String,Object> param) {
        return baseSysConfigsService.updateAdvertising(param);
    }

    /**
     * 热门搜索词更新
     * @param param
     * @return
     */
    @PostMapping("/updateHotWord")
    public ResponseResult updatehotword(@RequestBody Map<String,Object> param) {
        return baseSysConfigsService.updatehotword(param);
    }

    /**
     * feign 通过key查询广告位
     *
     * @return
     */
    @PostMapping("/queryMePage")
    public ResponseResult queryMePage() {
        return baseSysConfigsService.queryMePage();
    }

    /**
     * 获取颜色
     * @param webConfig
     * @return
     */
    @PostMapping("/queryWapColorForUniApp")
    public ResponseResult queryWapColorForUniApp(@RequestBody WebConfigDTO webConfig) {
        return baseSysConfigsService.queryWapColorForUniApp();
    }


    /**
     *   查询平台经营规则
     */
    @PostMapping("/queryOperation")
    public ResponseResult queryplatformoperation(){
        return baseSysConfigsService.queryplatformoperation();
    }


    /**
     *   更新平台经营规则
     */
    @PostMapping("/updateOperation")
    public ResponseResult updateoperation(@RequestBody Map<String,Object> map){
        return baseSysConfigsService.updateoperation(map);
    }


    /**
     * @Param:  设置质保金通用额度
     */
    @PostMapping("/updateCatMoney")
    public ResponseResult updatecatmoney(@RequestBody Map<String,Object> map){
        return  baseSysConfigsService.updatecatmoney(map);

    }

    /**
     * @Param:  查询质保金通用额度
     */
    @PostMapping("/queryCatMoney")
    public ResponseResult querycatmoney(){
        return  baseSysConfigsService.querycatmoney();
    }




}
